#include "image_own.h"

using namespace cv_camera_state;

void CameraState::run()
{
	// 参数默认配置
	std::string front_camera("/cv_camera/front_camera_state");
	std::string back_camera("/cv_camera/back_camera_state");
	bool front_camera_state;
	bool back_camera_state;
	nh_private.getParam("front_camera", front_camera);
    nh_private.getParam("back_camera", back_camera);
	nh_private.getParam("front_camera_state", front_camera_state);
    nh_private.getParam("back_camera_state", back_camera_state);

    ros::Publisher state_pub = nh_private.advertise<std_msgs::Bool>(front_camera, 1);
    std_msgs::Bool front_camera_bool;
    front_camera_bool.data = front_camera_state;

    ros::Rate rate(1);
	while(ros::ok()) {
        state_pub.publish(front_camera_bool);
        struct timespec time0 = {0, 0};
        clock_gettime(CLOCK_REALTIME, &time0);
        ROS_WARN("CameraState start_time: %ld.%ld s", time0.tv_sec, time0.tv_nsec);
        rate.sleep();
        ros::spinOnce();
	}

}

CameraState::CameraState()
    : nh_private("~")
{
    run();
}

CameraState::~CameraState()
{

}
